﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace Bzure.Mvc.Html
{
    public static class StyleHelper
    {
        public static string ThemeStyle(this HtmlHelper helper, string url)
        {
            return helper.Style(Actor.Public.Url().ThemeContent(url));
        }
        public static string ThemeAreaStyle(this HtmlHelper helper, string AreaName, string url)
        {
            return helper.Style(Actor.Public.Url().ThemeAreaContent(AreaName, url));
        }
        public static string GenericThemeStyle(this HtmlHelper helper, string url)
        {
            return helper.Style(Actor.Public.Url().GenericThemeContent(url));
        }
        public static string GenericThemeAreaStyle(this HtmlHelper helper, string AreaName, string url)
        {
            return helper.Style(Actor.Public.Url().GenericThemeAreaContent(AreaName, url));
        }
        //<link href="" rel="stylesheet"    type="text/css" />
        static string Style(this HtmlHelper helper, string url)
        {
            // Create tag builder
            var builder = new TagBuilder("link");
            // Add attributes
            builder.MergeAttribute("href", url);
            builder.MergeAttribute("rel", "stylesheet");
            builder.MergeAttribute("type", "text/css");
            // Render tag
            return builder.ToString(TagRenderMode.SelfClosing);
        }
    }
    public static class ScriptHelper
    {
        public static MvcHtmlString ThemeScript(this HtmlHelper helper, string url)
        {
            return helper.Script(Actor.Public.Url().ThemeContent(url));
        }
        public static MvcHtmlString ThemeAreaScript(this HtmlHelper helper, string AreaName, string url)
        {
            return helper.Script(Actor.Public.Url().ThemeAreaContent(AreaName, url));
        }
        public static MvcHtmlString GenericThemeScript(this HtmlHelper helper, string url)
        {
            return helper.Script(Actor.Public.Url().GenericThemeContent(url));
        }
        public static MvcHtmlString GenericThemeAreaScript(this HtmlHelper helper, string AreaName, string url)
        {
            return helper.Script(Actor.Public.Url().GenericThemeAreaContent(AreaName, url));
        }
        static MvcHtmlString Script(this HtmlHelper helper, string url)
        {
            string s = string.Format("<script src=\"{0}\" type=\"text/javascript\"></script>", url);

            return MvcHtmlString.Create(s);
        }
    }

}
